package model;

import java.util.Enumeration;
import java.util.Vector;

import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeNode;

public class NodeFolder implements MutableTreeNode {

	// class for folder nodes
	
	public String folderName;
	
	public NodeFolder(String folderName) {
		super();
		this.folderName = folderName;
	}
	
	@Override
	public String toString(){
		return folderName;
	}

	private MutableTreeNode parent;
	private Vector<MutableTreeNode> children = new Vector<MutableTreeNode>();
	
	@Override
	public Enumeration<MutableTreeNode> children() {
		return children.elements();
	}

	@Override
	public boolean getAllowsChildren() {
		return true;
	}

	@Override
	public TreeNode getChildAt(int childIndex) {
		return (TreeNode) children.get(childIndex);
	}

	@Override
	public int getChildCount() {
		return children.size();
	}

	@Override
	public int getIndex(TreeNode node) {
		return children.indexOf(node);
	}

	@Override
	public TreeNode getParent() {
		return this.parent;
	}

	@Override
	public boolean isLeaf() {
		return children.isEmpty();
	}

	@Override
	public void insert(MutableTreeNode child, int index) {
		children.add(index, child);
	}

	@Override
	public void remove(int index) {
		children.remove(index);
	}

	@Override
	public void remove(MutableTreeNode node) {
		children.remove(node);
	}

	@Override
	public void removeFromParent() {
		this.parent.remove(this);
		this.parent = null;
	}

	@Override
	public void setParent(MutableTreeNode newParent) {
		this.parent = newParent;
	}

	@Override
	public void setUserObject(Object object) {
		// TODO Auto-generated method stub

	}

}
